package com.fengwk.support.code;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import com.fengwk.support.util.CodeUtils;

@Component
@ConfigurationProperties("sequence")
public class Sequence {

	private static long SERVER_INDEX = 0L;// 服务器序号
	private static long NODE_INDEX = 0L;// 节点序号

	public void setServerIndex(long serverIndex) {
		SERVER_INDEX = serverIndex;
	}

	public void setNodeIndex(long nodeIndex) {
		NODE_INDEX = nodeIndex;
	}
	
	public static long next() {
		return CodeUtils.snowflake(SERVER_INDEX, NODE_INDEX);
	}
	
}
